﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;

namespace RssReaderTemplate.Model.TagProcessors
{
    public static class TagProcessorCollection
    {
        private static readonly IDictionary<string, TagProcessor> _tagProcessors = new Dictionary<string, TagProcessor>();
        public static void RegisterTagProcessor(TagProcessor processor)
        {
            if (processor.Tag == null)
            {
                throw new ArgumentNullException("processor.Tag");
            }
            if (processor == null)
            {
                throw new ArgumentNullException("processor");
            }
            if (_tagProcessors.ContainsKey(processor.Tag))
            {
                throw new ArgumentException("There is already a processor for that tag", "tag");
            }
            _tagProcessors.Add(processor.Tag, processor);
        }

        public static TagProcessor GetProcessor(string tag)
        {
            TagProcessor res;
            return _tagProcessors.TryGetValue(tag, out res) ? res : null;
        }
    }
}
